package aco;

public class InOut {

    static int n_tours; /* counter of number constructed tours */
    static int iteration; /* iteration counter */
    static double lambda; /* Parameter to determine branching factor */

    static int noEvaluations = 0; /* 求解次数 */
    static int noSolutions = 0;   /* counter for the total number of feasible solutions */

    static double pheromonePreservation;

    // 计算距离方法的枚举类型
    enum Distance_type {EUC_2D, CEIL_2D, GEO, ATT};
    static Distance_type distance_type;

    // 为算法设置默认参数
    static void set_default_parameters() {
        Ants.n_ants = 25; /* number of ants */
        Ants.nn_ants = 20; /* number of nearest neighbors in tour construction */
        Ants.alpha = 1.0;
        Ants.beta = 2.0;
        Ants.rho = 0.5;
        Ants.q_0 = 0.0;
        distance_type = Distance_type.EUC_2D; /* 计算距离方法 */

    }

    /**
     * 初始化优化程序
     * @param instance 算例
     * @param saclingValue
     */
    static void init_program(VRPTW instance, double saclingValue){
        // 1.设置默认参数
        set_default_parameters();
        // 2.设置蚁群中蚂蚁数量 allocate ants
        if (Ants.n_ants<0){
            Ants.n_ants = VRPTW.n;
        }
        // 3.compute distance matrix between cities(计算距离矩阵)
        VRPTW.instance.distance = VRPTW.compute_distances(saclingValue);
        // 4.重置蚁群和最优蚂蚁
        Ants.allocate_ants(instance);
    }
}
